package com.teziyou.test;

import com.mytravel.commodityBridge.pool.ConnectionManager;
import com.mytravel.commodityBridge.pool.ConnectionProviderImpl;
import com.mytravel.commodityBridge.proxy.ThriftClientProxy;
import com.mytravel.commodityBridge.service.TicketInfoService;
import com.mytravel.commodityBridge.service.bean.OnSaleTicket;

public class CommodityThriftClient {
	public static void main(String[] args) throws Exception {
		//218.240.21.155
		//127.0.0.1
		String serviceURL = "218.240.21.155:7911";
//		String serviceURL = "127.0.0.1:7911";
		ConnectionProviderImpl connectionProvider = new ConnectionProviderImpl();
		connectionProvider.setServiceURL(serviceURL);
		connectionProvider.setConnTimeout(12000);
		connectionProvider.afterPropertiesSet();
		
		ConnectionManager connectionManager = new ConnectionManager();
		connectionManager.setConnectionProvider(connectionProvider);
		
		ThriftClientProxy tcp = new ThriftClientProxy();
		tcp.setConnectionManager(connectionManager);
		
//		HelloWorldService.Client obj = (HelloWorldService.Client)tcp.getHelloWorldServiceClient();
//		System.out.println(obj.sub(10, 20));	
		TicketInfoService.Client obj = tcp.getTicketInfoServiceClient();
		
//		1根据商品id获取商品的图片列表  
//		List getPictruesOfGoods(long id) 
//		System.out.println(obj.getImageListById(10001l));
		
//		获取详情页推荐的商品
//		List getRecommendedGoods();
		/*java.util.List<OnSaleTicket> list = obj.getRecommendedGoods();
		for (int i = 0; i < list.size(); i++) {
			OnSaleTicket temp = list.get(i);
			System.out.println(temp.getOnSaleId());
		}*/
		
//		根据该商品的评论
//		java.util.List getCommentsOfGoods(long id，int pageNo,int pageSize)
//		java.util.List<TicketComments> list = obj.getCommentPageListById(30001, 1, 5);
//		for (int i = 0; i < list.size(); i++) {
//			TicketComments temp = list.get(i);
//			System.out.println(temp.getCommentId());
//		}
		
//		评论商品返回评论结果(success or fail)
//		boolean discussGoods（Comment comment）
//		TicketComments record = new TicketComments();
//		record.setOnSaleId(33311);
//		record.setId(33322);
//		record.setDictionaryid(33333);
//		record.setDicDictionaryid(33344);
//		record.setDicDictionaryid2(33355);
//		record.setComment("测试");
//		record.setComTime("2014-09-05 01:02:03");
//		obj.discussGoods(record);
		
	}
}
